package com.zhouxiaoge.职责链模式.two;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

/**
 * @author 周小哥 gqzmy@163.com 2022/10/8 13:59
 */

public class ClientTest {
    public static void main(String[] args) {
        Random rand = new Random();
        List<IWomen> arrayList = new ArrayList<>();
        for (int i = 0; i < 5; i++) {
            arrayList.add(new Women(rand.nextInt(4), "我要出去逛街"));
        }
        // 定义三个请示对象
        Handler father = new Father(1);
        Handler husband = new Husband(2);
        Handler son = new Son(3);

        father.setNextHandler(husband);
        husband.setNextHandler(son);

        for (IWomen women : arrayList) {
            father.handleMessage(women);
        }
    }
}
